﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Xml.Serialization;
using System.IO;
using Emico.Linq.Criterion;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;

namespace Emico.Core.Tests.Criterion
{
    [TestClass]
    public class OrderByTest
    {
        [TestMethod]
        public void TestSerialize()
        {
            string propertyName = "Name";

            OrderBy<TestType> order = new OrderBy<TestType>(propertyName);
            using(MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(ms, order);

                ms.Position = 0;
                var result = (OrderBy<TestType>)bf.Deserialize(ms);

                Assert.AreEqual(propertyName, result.PropertyName);
            }
        }
    }
}
